﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Bluyel.Core
{
    /// <summary>
    /// Data Named enum. values are type string.
    /// </summary>
    public class DEnumString : DEnumBase, IDEnumString
    {
        //=====================================================================
        #region Constructor.

        //---------------------------------------------------------------------
        /// <summary>
        /// Constructor.
        /// Be carrefull to provide the typeLOV basic.
        /// </summary>
        /// <param name="name"></param>
        public DEnumString(string name, ITypeEnum type)
            : base(name, type)
        {
        }
        #endregion

        //=====================================================================
        #region Properties.

        //---------------------------------------------------------------------
        public new ITypeEnumString TypeEnum
        { get { return Type as ITypeEnumString; } }


        //---------------------------------------------------------------------
        /// <summary>
        /// Return the selected value, can be null.
        /// If selection mode is many, return the first one.
        /// </summary>
        public new ValueString SelectedVal
        {
            get { return base.SelectedVal as ValueString; }
        }

        //---------------------------------------------------------------------
        /// <summary>
        /// Return the list of selected values
        /// </summary>
        public new IEnumerable<ValueString> ListSelectedVal
        {
            get
            {
                // convert each value to a DValString
                List<ValueString> list = new List<ValueString>();
                foreach (IValue val in base.ListSelectedVal)
                    list.Add(val as ValueString);

                return list;
            }
        }

        #endregion
    }
}
